package com.g.places.api.base;

import com.g.places.api.model.GBasePlace;
import com.g.places.api.model.GPlace;
import com.g.places.api.util.Parameter;

/**
 * 
 * client for google places API 
 * you need API key from google to use this project 
 * 
 * <ul>
 * <li>Fetch an objects: use {@link #fetchGPlaces(String baseUrl ,OutputType outputType,
			Class<T> objectType , Parameter ...parameters}</li>
 * </ul>
 * 
 *  please @See Limits and Requirements for Google Places API / Apache  before use this project
 *
 */
public interface PlacesClient {

	
	// an HTTP URL represent A Places Search request 
	public static String SEARCH_TEXT_PLACES_BASE_URL = "https://maps.googleapis.com/maps/api/place/textsearch/";

	// an HTTP URL represent A Place Details Search request 
	public static String SEARCH_TEXT_PLACE_DETAILS_BASE_URL = "https://maps.googleapis.com/maps/api/place/details/";
	
	//  Place Search response object contains the status of the request
	public static StatusResponse STATUS_OK    = StatusResponse.OK;
	
	
	/**
	 * fetching data from google places API by using google web service for google places API 
	 * 
	 * 
	 * @param baseUrl       
	 * 						base URL to gather Places from google places API   
	 * @param outputType     
	 * 						ENUM represent output type either JSON / XML 
	 * @param objectType	
	 * 						class type for result @See {@link GPlace}
	 * @param parameters    
	 * 						request parameters to add to URL
	 *  
	 * @return fetched data from Google Places the result object must match given URL   
	 */
	public <T extends GBasePlace> T fetchGPlaces(String baseUrl ,OutputType outputType,
			Class<T> objectType , Parameter ...parameters );

	
	
	/**
	 * 
	 * Simple API Access
	 * @see 
	 * @author ahmad
	 */
	public static class SimpleApiAccess {
		
		// simple API access
		private String gAPIKey;

		public SimpleApiAccess() {
			
		}
		
		public SimpleApiAccess(String gAPIKey) {
			this.gAPIKey = gAPIKey;
		}
		
		public String getgAPIKey() {
			return gAPIKey;
		}

		public void setgAPIKey(String gAPIKey) {
			this.gAPIKey = gAPIKey;
		}
		
	}
	
	/**
	 *  Output type 
	 * 	NOTE : WE IMPLEMENT ONLY JSON OUTPUT FOR NOW 
	 *
	 */
	public enum OutputType {
		
		JSON,
		XML
		
	}
	
	
	/**
	 * response status 
	 * 
	 *
	 *@see https://developers.google.com/places/documentation/#PlaceSearchStatusCodes
	 */
	public enum StatusResponse {
		
		OK, ZERO_RESULTS, OVER_QUERY_LIMIT, REQUEST_DENIED, INVALID_REQUEST
	}
	
	
	/**
	 * Language code 
	 * @author ahmad
	 *
	 */
	public enum LanguageCode {
		
		ENGLISH("en"),FRENCH("fr");
		
		private String code;
		
		private LanguageCode(String lh) {
			code = lh;
		}
		
		public String getCode() {
			return code;
		}
		
	}
}
